package com.atguigu.guli.service.edu.controller;


import com.atguigu.guli.service.edu.entity.Teacher;
import com.atguigu.guli.service.edu.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 讲师 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2021-11-24
 */
@RestController
@RequestMapping("/edu/teacher")
public class TeacherController {
    @Autowired
    TeacherService teacherService;
    //查询所有讲师
//    @ResponseBody
    @GetMapping("list")  //restController中的接口返回值会被转为json
    public List<Teacher> queryAll(){
        return teacherService.list();
    }
    //新增讲师
    @PostMapping("save")
//    public String save(Teacher teacher){ //POJO入参  url?name=xx&age=xxx&xxx
    public String save(@RequestBody Teacher teacher){ //获取请求体参数： 以json的方式存到请求体中
        return teacherService.save(teacher)?"成功":"失败";
    }
}

